/*
 * TextFieldDelegate.h  0.4.0 / Dec 05, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
#ifndef TEXTFIELDDELEGATE_H
#define TEXTFIELDDELEGATE_H

#include "Cute4jSwing.h"

#include "ComponentDelegate.h"

// TextFieldDelegate Class. ----------------------------------------------------

/*!
 * \brief TextField Delegate.
 *
 * \author Slobodan Vrkacevic
 * \version 0.4.0
 */
class CUTE4J_EXPORT TextFieldDelegate : public ComponentDelegate
{
  Q_OBJECT
protected:
  TextFieldDelegate(JNIEnv *env, jobject obj);
public slots: // native calls
  jstring getText(JNIEnv *env);
  void setText(JNIEnv *env, jstring text);
  void setHorizontalAlignment(JNIEnv *env, jint alignment);
public: // native calls
  static void initialize(JNIEnv *env, jclass cls);
  static jlong newInstance(JNIEnv *env, jobject obj);
public: // native callbacks
  void returnPressed(jint modifiers);
public:
  inline QLineEdit *qLineEdit() const;
protected slots:
  void returnPressedSlot();
private:
  static jmethodID sm_returnPressedMID;
};

// TextFieldDelegate :: Inline Member Function. --------------------------------

/*!
 * \brief Returns QLineEdit adaptee.
 *
 * \return QLineEdit adaptee
 */
inline QLineEdit *TextFieldDelegate::qLineEdit() const
{
  return static_cast<QLineEdit *>(qObject());
}

// Macro Definitions. ----------------------------------------------------------

#define TEXT_FIELD_DELEGATE (reinterpret_cast<TextFieldDelegate *>(delegate))

#endif // TEXTFIELDDELEGATE_H
